package game;

import java.awt.Color;
import java.io.File;

public class BrickBreakAnimation extends ParticleAnimation {
	private int index;
	private Color brown = new Color(180, 90, 0);
	private ClipPlayer wav;
	private Level lvl;
	
	public BrickBreakAnimation(Level g, int x, int y){
		super(g,x,y);
		index = 0;
		lvl = g;
		wav = new ClipPlayer("images/brick.wav", level.canvas.settings.soundVolume);
		if(!lvl.canvas.muted)
		level.canvas.addMusic(wav);
	}
	
	public void update(){
		index += 10;
		if(index > 200){
			level.animations.remove(this);
			if(!lvl.canvas.muted){
				wav.finish();
				level.canvas.stopMusic(wav);
			}
		}
	}
	
	public void draw(){
		level.canvas.bufGraphics.setColor(brown);
		level.canvas.bufGraphics.fillRect(orgin.x+index-level.canvas.currentX, (int)(orgin.y+.01*Math.pow(index, 2))-index, 10, 10);
		level.canvas.bufGraphics.fillRect(orgin.x-index-level.canvas.currentX, (int)(orgin.y+.01*Math.pow(index, 2))-index, 10, 10);
		level.canvas.bufGraphics.fillRect(orgin.x+index-level.canvas.currentX, (int)(orgin.y+.01*Math.pow(index, 2))-2*index, 10, 10);
		level.canvas.bufGraphics.fillRect(orgin.x-index-level.canvas.currentX, (int)(orgin.y+.01*Math.pow(index, 2))-2*index, 10, 10);
	}
}
